import mitt, { Emitter } from 'mitt'
import { inject, provide } from 'vue'
export const RootEmit = mitt()

/**
 *
 * @param name
 */
export function definedEmit(name = 'rootEmit') {
    const emit = mitt()
    provide(name, emit)
    return emit
}

/**
 *
 * @param name
 */
export function injectEmit(name = 'rootEmit'): Emitter<any> {
    const emit:any = inject(name)
    return emit
}

export function createEmit() {
    const emit = mitt()
    return emit
}
